package cn.shop.cloud.web.controller;

import cn.shop.cloud.common.Result;
import cn.shop.cloud.service.ISeckillGoodService;
import cn.shop.cloud.web.vo.SeckillGoodVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @program: shop-parent
 * @ClassName SeckillGoodController
 * @description:
 * @author: Mokio
 * @create: 2024−12-24 21:15
 * @Version 2024 2.2 ; jdk1.8.0_181
 **/
@RestController
@RequestMapping("/seckillGood")
public class SeckillGoodController {


    @Autowired
    private ISeckillGoodService seckillGoodService;
    //  http://localhost:9000/seckill/seckillGood/query

    @RequestMapping("/query")
    public Result<List<SeckillGoodVo>> query(){
        List<SeckillGoodVo> seckillGoodVoList = seckillGoodService.query();
        return  Result.success(seckillGoodVoList);
    }

    /*
       都是单表查询 ，需要在内存中进行聚合
       将两张表的数据进行映射
       good-api  下面 有个Good类---> t_goods

       seckill-api 下面 需要有个 SeckillGood类

       远程调用
          seckill-server
             调用
          good-server



     */

    // http://localhost:9000/seckill/seckillGood/find?seckillId="+seckillId

    /**
     * 根据场次id 查询商品信息
     * @param seckillId
     * @return
     */
    @RequestMapping("/find")
    public  Result<SeckillGoodVo> find(Long seckillId){
        SeckillGoodVo seckillGoodVo = seckillGoodService.find(seckillId);
        return Result.success(seckillGoodVo);

    }


}
